import wiringpi as gpio
import time
import sys

pins = (11)

def set_pin():
    gpio.wiringPiSetup()

    gpio.pinMode(11, 1)


    try:
        gpio.digitalWrite(11, 1)
    except KeyboardInterrupt:
        print('exit')

def test_mode(pin):
    m = gpio.gpio_function(pin)
    if m == gpio.IN:
        print('GPIO.IN')
    elif m == gpio.OUT:
        print('GPIO.OUT')
    elif m == gpio.SPI:
        print('GPIO.SPI')
    elif m == gpio.I2C:
        print('GPIO.I2C')
    elif m == gpio.HARD_PWM:
        print('GPIO.HARD_PWM')
    elif m == gpio.SERIAL:
        print('GPIO.SERIAL')
    elif m == gpio.UNKNOWN:
        print('GPIO.UNKNOWN')

if __name__ == '__main__':
    args = sys.argv
    cmd = args[1]
    if cmd == 'test_mode':
        test_mode(int(args[2]))
    elif cmd == 'set_pin':
        set_pin()
